home *** CD-ROM | disk | FTP | other *** search
- /* Windows Initialization Files -- sample source code Listing 3
- * Kevin H. Carlson 8/07/91
- */
-
- /* The WIN.INI file contains a section named [windows] that has a
- * key called device. For the purpose of this example, that line
- * is given to be:
- *
- * [windows]
- * device=PostScript Printer,PSCRIPT,LPT1:
- *
- */
-
-
- .
- .
- .
-
- HDC hPrinterDC;
- char deviceStr[80];
- int resultLength;
- LPSTR driverName;
- LPSTR deviceName = NULL;
- LPSTR output = NULL;
-
- // create printer DC
- resultLength = GetProfileString((LPSTR)"windows", (LPSTR)"device",
- "", deviceStr, sizeof(deviceStr));
-
- /* replace commas with Nulls and set parameter pointers */
- driverName = (LPSTR) deviceStr;
- for(i = 0; i < resultLength; i++)
- {
- if(deviceStr[i] == ',')
- {
- deviceStr[i] = '\0';
- if(!deviceName)
- deviceName = &deviceStr[i+1];
- else
- {
- output= &deviceStr[i+1];
- break;
- }
- }
- }
-
- /* create printer DC */
- hPrinterDC = CreateDC(deviceName, driverName, output, NULL);
-
- .
- .
- .
-